{% extends "layout/basic.html" %}
{% load static %}

{% block title %}
    用户登录
{% endblock %}

{% block css %}
    <link rel="stylesheet" href="{% static "css/account.css" %}">
    <style>
        .err_msg {
            color: red;
            position: absolute;
        }
    </style>
{% endblock %}

{% block content %}
    <div id="app">
        <div class="account">
            <h1 class="title">短信登录</h1>
            <form method="post">
                {% csrf_token %}
                {% for field in form %}
                    {% if field.label == "验证码" %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            <div class="clearfix">
                                <div class="col-md-6" style="padding-left: 0">{{ field }}</div>
                                <div class="col-md-6">
                                    <a id="send_sms" @click="get_verify_sms" type="button" class="btn btn-default">[[
                                        send_sms_message ]]</a>
                                    {% if sms_err_code == 100 %}
                                        <p><span class="err_msg">{{ sms_errmsg }}</span></p>
                                    {% endif %}
                                </div>

                            </div>
                        </div>
                    {% else %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            <div>{{ field }}</div>
                            <span v-show="{{ field.name }}_error"
                                  class="err_msg">[[ {{ field.name }}_error_msg ]]</span>
                        </div>
                    {% endif %}
                {% endfor %}
                <span class="err_msg">{{ err_msg }}</span>
                <div>
                    <div style="float: right">
                        <a href="{% url "login_sms" %}">用户名登录</a>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-3">
                        <button class="btn-primary" type="submit">登录</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
{% endblock %}

{% block js %}
    <script src="{% static "js/vue-3.1.2.js" %}"></script>
    <script src="{% static "js/axios-0.18.0.min.js" %}"></script>
    <script src="{% static "js/login_sms.js" %}"></script>
{% endblock %}